package jmine.tec.utils.spring.http;

import jmine.tec.utils.spring.InstanceResolver;

/**
 * @author takeshi
 * @param <E> type
 */
public abstract class AbstractInstanceResolver<E> implements InstanceResolver<E> {

    /**
     * @return {@link Object}
     */
    @SuppressWarnings("unchecked")
    public final E getInstance() {
        E o = this.resolveInstance();
        if (o != null && o instanceof InstanceResolver) {
            return ((InstanceResolver<E>) o).getInstance();
        }
        return o;
    }

    /**
     * To be overriden by subclasses.
     * 
     * @return {@link Object}
     */
    protected abstract E resolveInstance();
}
